package service

import (
	"fmt"
	"github.com/go-xorm/xorm"
	"log"
	"webIm/model"
)

var DbEngin *xorm.Engine

func init() {
	drivename := "mysql"
	Dsname := "root:123456@(127.0.0.1:3306)/chat?charset=utf8"

	DbEngin, err := xorm.NewEngine(drivename, Dsname)
	if err != nil && err.Error() != "" {
		log.Fatal(err.Error())
	}
	fmt.Println("init mysql data")
	//显示sql语句
	DbEngin.ShowSQL(true)
	////设置数据库最大连接数
	DbEngin.SetMaxOpenConns(2)
	//
	////自动建表user
	DbEngin.Sync2(new(model.User))
	fmt.Println("init mysql data")

}
